package com.example.medical.service.impl;
import com.example.medical.domain.Shop;
import com.example.medical.mapper.ShopMapper;
import com.example.medical.service.ShopService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ShopServiceImpl implements ShopService {

    @Autowired
    ShopMapper mapper;

    // 获取所有店铺信息列表
    @Override
    public List<Shop> selectAll() {
        return mapper.selectAll();
    }

    // 根据店铺id获取对应的店铺信息
    @Override
    public Shop selectById(int id) {
        return mapper.selectById(id);
    }

    // 保存（新增）店铺信息，返回操作影响的行数等用于判断操作是否成功（可按实际情况调整返回值含义）
    @Override
    public int saveShop(Shop shop) {
        return mapper.saveShop(shop);
    }

    // 更新店铺信息逻辑，调用Mapper层方法根据传入的店铺对象更新数据库中对应记录
    @Override
    public int updateShop(Shop shop) {
        return mapper.updateShop(shop);
    }

    // 删除店铺逻辑，调用Mapper层方法根据传入的店铺id删除数据库中对应记录
    @Override
    public int deleteShop(int id) {
       return mapper.deleteShop(id);
    }

    // 检查店铺相关登录验证等逻辑（比如验证店铺账号密码是否匹配等，具体按实际需求定），返回相应提示信息等
    @Override
    public String checkShop(Shop shop) {
        int res = mapper.checkShop(shop);
        if (res == 1) {
            return "店铺登录成功";
        } else {
            return "店铺账号或密码错误";
        }
    }
}